package com.oasys.controller;

import com.oasys.entity.EmployPo;
import com.oasys.entity.EmployVo;
import com.oasys.service.EmployService;
import com.oasys.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2022/5/14
 * 员工信息
 **/
@RestController
@RequestMapping("/employInfo")
@Slf4j
@Api("员工信息接口")
public class EmployController {

    @Resource
    private EmployService employService;

    /**
     * get
     * @param employVo
     * @return
     */
    @PostMapping("/getEmployInfo")
    @ApiOperation("获取员工数据")
    public ResponseResult<Map<String,Object>> getEmployInfo(@RequestBody EmployVo employVo){
        log.info("请求参数：{}",employVo.toString());
        return employService.getEmployInfo(employVo);
    }

    /**
     * update
     * @param employPo
     * @return
     */
    @PostMapping("/updateStaffInfo")
    @ApiOperation("修改员工信息")
    public ResponseResult<Boolean> updateStaffInfo(@RequestBody EmployPo employPo){
        return employService.updateStaffInfo(employPo);
    }

    /**
     * prohibit
     * @param sid 离职
     * @return
     */
    @PostMapping("/prohibitEmploy")
    @ApiOperation("员工离职")
    public ResponseResult<Boolean> prohibitEmploy(String sid){
        log.info("sdi:{}",sid);
        return employService.prohibitEmploy(sid);
    }

    /**
     * prohibit
     * @param sid 入职
     * @return
     */
    @PostMapping("/inductionEmploy")
    @ApiOperation("员工离职")
    public ResponseResult<Boolean> inductionEmploy(String sid){
        log.info("sdi:{}",sid);
        return employService.inductionEmploy(sid);
    }

    /**
     * 获取个人信息
     * @return
     */
    @GetMapping("/getSelfInfo")
    public ResponseResult<EmployPo> getSelfInfo(){
        return employService.getSelfInfo();
    }

    /**
     * 上传简历
     * @return 简历地址
     */
    @PostMapping("/uploadResume")
    public ResponseResult<String> uploadResume(@RequestParam(value="file",required=false) MultipartFile multipartFile) {
        ResponseResult<String> responseResult = new ResponseResult<>();
        responseResult.setData(employService.uploadResume(multipartFile));
        return responseResult;
    }

    /**
     * 获取简历下载地址
     *
     * @return 简历下载地址
     */
    @GetMapping("/getResume")
    public ResponseResult<String> getResume(Long userId) {
        ResponseResult<String> responseResult = new ResponseResult<>();
        responseResult.setData(employService.getResumeByUserId(userId));
        return responseResult;
    }


}
